﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using OnlineCourse.Model.Entity;
using System;
using System.Collections.Generic;
using System.Text;

namespace OnlineCourse.Model.EntityConfiguration
{
  public  class CouponConfiguration: IEntityTypeConfiguration<Coupon>//抽象泛型继承类
    {
        public void Configure(EntityTypeBuilder<Coupon> builder)
        {
            builder.Property(a => a.Id).HasDefaultValueSql("newid()");
            builder.Property(a => a.Title).HasMaxLength(150).IsRequired();//指定字段长度，并且指定他不能为null
            builder.Property(a => a.Price).HasColumnType("decimal(18,6)");
        }
    }
}
